package linwen.wang.controller;

import linwen.wang.common.service.CommonService;
import linwen.wang.entity.User;
import linwen.wang.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName UserController
 * @Description TODO
 * @Author zero
 * @DATE 2024/4/23 2:44 AM
 * @Version 1.0
 */
@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {

    @Autowired
    private UserService userService;

    @Autowired
    private CommonService commonService;

    @RequestMapping("/getUserById")
    public User getUserById(Long id) {
        log.info("commonService:{}",commonService);
        User user = userService.getUserById(id);
        log.info("user:{}", user);
        return user;
    }

    @RequestMapping("/insertUser")
    public String insertUser(UserVO userVo) {
        log.info("insertUser");
        User user = new User();
        BeanUtils.copyProperties(userVo, user);
        userService.insertUser(user);
        return String.valueOf(user.getId());
    }



}
